<template>
	<el-config-provider :locale="config.locale" :size="config.size" :zIndex="config.zIndex" :button="config.button">
		<router-view></router-view>
	</el-config-provider>
</template>

<script>
	import colorTool from '@/utils/color'
export default {
        name: 'App',
        data() {
            return {
                config: {
                    locale: this.$i18n.messages[this.$i18n.locale].el,
                    size: "default",
                    zIndex: 2000,
                    button: {
                        autoInsertSpace: false
                    }
                }
            }
        },
        created() {
            //设置主题颜色
            const app_color = this.$CONFIG.COLOR || this.$TOOL.data.get('APP_COLOR')
            if(app_color){
                document.documentElement.style.setProperty('--el-color-primary', app_color);
                for (let i = 1; i <= 9; i++) {
                    document.documentElement.style.setProperty(`--el-color-primary-light-${i}`, colorTool.lighten(app_color,i/10));
                }
                for (let i = 1; i <= 9; i++) {
                    document.documentElement.style.setProperty(`--el-color-primary-dark-${i}`, colorTool.darken(app_color,i/10));
                }
            }
        },
//移动端和PC端的判断
        /*mounted() {
            if (this._isMobile()) {
                this.$router.replace('/m');
            } else {
                this.$router.replace('/');
            }
        },
        methods:{
            _isMobile() {
                let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
                return flag;
            }
        }*/
    }
</script>

<style lang="scss">
	@import '@/style/style.scss';
</style>